<% include head.ejs%>
<body>
<div class="wp">
    <header class="t-header">
        <div class="topbar">
            <a href="/usr/index" class="gobakA fl">
                <i class="icon-angle-left"></i>
            </a>
            <span>我的交易</span>
        </div><!-- topbar end -->
    </header>
    <div class="myDealmenuCl clearfix">
        <li>
            <a id="0" class="dealtype <% if(dealtype == 0){%> on <%}%>">全部</a>
        </li>
        <li>
            <a id="2" class="dealtype <% if(dealtype == 2){%> on <%}%>">待付款</a>
        </li>
        <li>
            <a id="3" class="dealtype <% if(dealtype == 3){%> on <%}%>">待发货</a>
        </li>
        <li>
            <a id="4" class="dealtype <% if(dealtype == 4){%> on <%}%>">已发货</a>
        </li>
        <li>
            <a id="9" class="dealtype <% if(dealtype == 9){%> on <%}%>">失败</a>
        </li>
    </div>

    <div class="myDeal-listWp">
        <div id="prodlist" class="myDeal-list <% if(prods.length == 0){%>hide<%}%>">

            <div class="myDeal-item">
                <% for (var i in prods){%>
                <div class="info">
                    <a href="#" class="clearfix">
                        <div class="pic">
                            <img src="<%= prods[i].product_icon%>">
                        </div>
                        <div class="txt">
                            <h1><%= prods[i].product_name%></h1>
                            <div class="prce clearfix">
                                <span class="p fl">￥<%= prods[i].prod_price/100%></span>
                                <span class="n fr">x<%= prods[i].prod_sum%></span>
                            </div>
                        </div>
                    </a>
                </div>
                <%}%>
                <div class="tjInfo">
                    共<span class="n"><%= totalsum%></span>件商品 合计：<span class="p">￥<%= Number(totalmoney)/100%></span><span class="yf">（含运费 ￥<%= freight[0].send_fee/100%>）</span>
                </div>
                <div class="btnBM">
                    <% if(dealtype == 4){%>
                    <a href="#" class="catWl">查看物流</a>
                    <a href="#" class="confirm on">确认收货</a>
                    <%}else if(dealtype == 2){%>
                    <a href="/order/payOrder" class="confirm on">去支付</a>
                    <%}%>

                </div>
            </div><!-- myDeal-item end -->

        </div><!--   myDeal-list  end --->

        <div id="emptyBox" class="emptyBox <% if(prods.length != 0){%>hide<%}%>">
            <img src="/images/no-more.png">
            <span>没有搜索到任何订单，快去商城挑选心爱的商品吧</span>
            <a class="goShoping-a" href="/prod/index">前去逛逛</a>
        </div>
    </div>


</div>
<script type="text/javascript">
    $(function(){

        $("#city_sel").sjld("#shenfen","#chengshi","#quyu");

        $(".dealtype").click(function () {
            $(this).siblings("").addClass("on");
            $(".dealtype.on").removeClass("on");
            var typeid = $(this).attr("id");
            $.get('/usr/getUserPdList',{typeId:typeid},function (datas) {
                $('#prodlist').html('');
                var data = JSON.parse(datas);
                var prods = data.prods;
                var plist = '<div class="myDeal-item">';
                for(var i in prods) {
                    plist += '<div class="info">';
                    plist += '<a href="#" class="clearfix">';
                    plist += '<div class="pic">';
                    plist += '<img src="'+ prods[i].product_icon+'">';
                    plist += '</div>';
                    plist += '<div class="txt">';
                    plist += '<h1>'+ prods[i].product_name+'</h1>';
                    plist += '<div class="prce clearfix">';
                    plist += '<span class="p fl">￥'+ prods[i].prod_price/100+'</span>';
                    plist += '<span class="n fr">x'+ prods[i].prod_sum+'</span>';
                    plist += '</div>';
                    plist += '</div>';
                    plist += '</a>';
                    plist += '</div>';
                }
                plist += '<div class="tjInfo">';
                plist += '共<span class="n">'+ data.totalsum+'</span>件商品 合计：<span class="p">￥'+ Number(data.totalmoney)/100+'</span><span class="yf">（含运费 ￥'+ Number(data.freight[0].send_fee)/100+'）</span>';
                plist += '</div>';
                plist += '<div class="btnBM">';
                if(data.dealtype == 4) {
                    plist += '<a href="#" class="catWl">查看物流</a>';
                    plist += '<a href="#" class="confirm on">确认收货</a>';
                }else if(data.dealtype == 2){
                    plist += '<a href="/order/payOrder" class="confirm on">去支付</a>'
                }
                plist += '</div>';
                plist += '</div>';
                $('#prodlist').append(plist);
                if(prods.length != 0){
                    $('#prodlist').removeClass('hide');
                    $('#emptyBox').addClass('hide');
                }else {
                    $('#emptyBox').removeClass('hide');
                    $('#prodlist').addClass('hide');
                }
            })
        });
    });
</script>
</body>
</html>